// ----------------------------------------
// Filename: Analog.h
// Description: Routines to implement ADC
// Author: Anton Jatmiko
// Date: 29-May-14

#ifndef ANALOG_H
#define ANALOG_H

#include <xc.h>
#include "types.h"

// ----------------------------------------
// Analog_Init
//
// Initialise ADC and its peripheral
// Input:
//   none
// Output:
//   none
// Conditions:
//   none
void Analog_Init(void);

// ----------------------------------------
// Analog_StartSampling
//
// Initialise ADC and its peripheral
// Input:
//   enable is a boolean indicates whether to start ADC conversion
// Output:
//   none
// Conditions:
//   ADC has been initialised
void Analog_StartSampling(BOOL enable);

// ----------------------------------------
// Analog_Read
//
// Read the ADC conversion result
// Input:
//   dataPtr is a pointer to the variable to store raw data
// Output:
//   none
// Conditions:
//   assume raw data is ready
void Analog_Read(TUINT16 * const dataPtr);

// ----------------------------------------
// Analog_Temperature
//
// Convert raw data to Celcius * 10
// Input:
//   dataPtr is a pointer to the temperature variable
// Output:
//   none
// Conditions:
//   none
void Analog_Temperature(TUINT16 * const dataPtr);

// ----------------------------------------
// Analog_SetInterrupt
//
// Arm or disarm ADC interrupt
// Input:
//   enable is a boolean indicates whether to arm or disarm ADC interrupt
// Output:
//   none
// Conditions:
//   none
void Analog_SetInterrupt(BOOL enable);

#endif